﻿using System.Collections.Concurrent;
using System.ComponentModel;

namespace JasLib
{
    /*****************************************************************************/
    public static class EventArgsCache
    {
        private static readonly ConcurrentDictionary<string, PropertyChangingEventArgs> s_propertyChangingEventArgsCache = new ConcurrentDictionary<string, PropertyChangingEventArgs>();
        public static PropertyChangingEventArgs GetNotifyPropertyChangingEventArgs(string strPropertyName)
        {
            return s_propertyChangingEventArgsCache.GetOrAdd(strPropertyName,
                str => new PropertyChangingEventArgs(string.Intern(str)));
        }

        private static readonly ConcurrentDictionary<string, PropertyChangedEventArgs> s_propertyChangedEventArgsCache = new ConcurrentDictionary<string, PropertyChangedEventArgs>();
        public static PropertyChangedEventArgs GetNotifyPropertyChangedEventArgs(string strPropertyName)
        {
            return s_propertyChangedEventArgsCache.GetOrAdd(strPropertyName,
                str => new PropertyChangedEventArgs(string.Intern(str)));
        }
    }

}
